<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>示例演示</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 注意：项目正式环境请勿引用该地址 -->
    <link rel="stylesheet" href="./layui/css/layui.css" th:href="@{/layui/css/layui.css}">
</head>
<body th:fragment="dictAddForm">

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>修改数据字典</legend>
</fieldset>

<form class="layui-form" action="/dict/data/add" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">id</label>
        <div class="layui-input-inline">
            <input type="text" name="id" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">字典名称</label>
        <div class="layui-input-inline">
            <input type="text" name="dictName" lay-verify="required" lay-reqtext="字典名称是必填项，岂能为空？" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">字典编码</label>
        <div class="layui-input-inline">
            <input type="text" name="dictCode" lay-verify="required" lay-reqtext="字典编码是必填项，岂能为空？" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">字典描述</label>
        <div class="layui-input-inline">
            <input type="text" name="dictDesc" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<!-- 注意：项目正式环境请勿引用该地址 -->
<script src="./layui/layui.js" th:src="@{/layui/layui.js}"></script>

<script>
    layui.use(function(){
        var form = layui.form;
        var laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 5){
                    return '标题至少得5个字符啊';
                }
            }
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
        });

        //提交事件
        form.on('submit(demo1)', function(data){
            alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })
            return true;
        });

    });
</script>

</body>
</html>